#include "tcp_server.hpp"
#include "epoll_loop.hpp"
#include "acceptor.hpp"

namespace rocket 
{

tcp_server::tcp_server(int port,string ip)
:_acceptor(port,ip)
,_loop(&_acceptor)
{
    _acceptor.start();

}

tcp_server::~tcp_server()
{
    
}
void tcp_server::turn_on()
{
    _loop.loop();
}

void tcp_server::turn_off()
{
    _loop.turn_off_loop();
}

void tcp_server::set_callback(function<void(shared_ptr<tcp_link>)>callback_new,
        function<void(shared_ptr<tcp_link>)>callback_old,
        function<void(shared_ptr<tcp_link>)>callback_close)
    {
        _loop.set_callback(callback_new, callback_old, callback_close);
    }



}
